<!doctype html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>图片预览 - {{ filename }}</title>
    
    <!-- Viewer.js CSS -->
    <link href="https://cdn.bootcdn.net/ajax/libs/viewerjs/1.10.5/viewer.min.css" rel="stylesheet">
    
    <!-- 引入阿里云CDN的Bootstrap -->
    <link href="https://cdifit.cn/cdn/bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <style>
        body {
            text-align: center;
            margin: 2em;
            font-family: 'Segoe UI', sans-serif; /* 统一字体 */
            background-color: #f4f7f6; /* 统一背景色 */
        }
        h1 {
            max-width: 90%; /* 优化小屏幕显示 */
            margin: 0 auto; /* 水平居中 */
            font-size: 2rem; /* 设置字体大小 */
            color: #333; /* 字体颜色 */
            margin-bottom: 1em; /* 底部边距 */
        }
        #image-container {
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
            margin: 1em 0;
        }
        #image-preview {
            max-width: 90%;
            height: auto;
            cursor: pointer;
            border-radius: 8px; /* 添加圆角 */
            box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1); /* 添加阴影 */
        }
        .download-button {
            margin-top: 1em; /* 增加按钮与图片之间的距离 */
        }
        
        h1, h2 {
            word-wrap: break-word; /* 处理长单词或标题的换行 */
        }
    </style>
</head>
<body>
    <h1>图片预览 - {{ filename }}</h1>
    <div id="image-container">
        <img id="image-preview" src="/file/{{ filename }}" alt="{{ filename }}">
        <p class="download-button"><a href="/file/{{ filename }}" class="btn btn-primary" download>点击下载文件</a></p>
    </div>

    <!-- Viewer.js JS -->
    <script src="https://cdn.bootcdn.net/ajax/libs/viewerjs/1.10.5/viewer.min.js"></script>
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const image = document.getElementById('image-preview');
            const viewer = new Viewer(image, {
                navbar: false,
                toolbar: {
                    zoomIn: 1,
                    zoomOut: 1,
                    oneToOne: 1,
                    reset: 1,
                    prev: 0,
                    play: {
                        show: 0,
                        size: 'large',
                    },
                    next: 0,
                    rotateLeft: 1,
                    rotateRight: 1,
                    flipHorizontal: 1,
                    flipVertical: 1,
                },
                viewed() {
                    viewer.zoomTo(1);
                },
            });
        });
    </script>
</body>
</html>
